import request from '@/utils/request'

export const manageGetAllCategory = () => {
  return request({
    url: '/manage/getAllCategory',
  })
}

export const manageGetAllFoods = () => {
  return request({
    url: '/manage/getAllFoods',
  })
}

export const manageGetAllSetMeal = () => {
  return request({
    url: '/manage/getAllSetmeal',
  })
}
// 根据name和type模糊查询classification
export const manageQueryCategoryLikeByNameOrType = ({ name, type }) => {
  return request({
    url: '/manage/queryCategoryLikeByNameOrType',
    params: {
      name,
      type,
    },
  })
}

// 根据id删除classification
export const manageDeleteCategoryById = ({ id }) => {
  return request({
    url: '/manage/deleteCategoryById',
    params: {
      id,
    },
  })
}

// 根据id修改classification
export const manageUpdateCategoryById = ({ id, type, name, sort }) => {
  return request({
    url: '/manage/updateCategoryById',
    method: 'patch',
    data: {
      id,
      type,
      name,
      sort,
    },
  })
}

// 根据id修改classification状态
export const updateCategoryStatusById = ({ id, status }) => {
  return request({
    method: 'patch',
    url: '/manage/updateCategoryStatusById',
    data: {
      id,
      status,
    },
  })
}
// 添加classification
export const addCategory = ({ type, name, sort }) => {
  // console.log(type, name, sort)

  return request({
    method: 'post',
    url: '/manage/addCategory',
    data: {
      type,
      name,
      sort,
    },
  })
}

// 模糊查询food
export const manageQueryFoodLikeByNameOrCategoryIdOrStatus = ({
  name,
  categoryName: categoryId,
  status,
}) => {
  console.log(name, categoryId, status)

  return request({
    url: '/manage/queryFoodLikeByNameOrCategoryIdOrStatus',
    params: {
      name,
      categoryId,
      status,
    },
  })
}

// 根据id删除food
export const manageDeleteFoodById = ({ id }) => {
  return request({
    method: 'delete',
    url: '/manage/deleteFoodById',
    params: {
      id,
    },
  })
}

// 根据id修改food的status
export const manageUpdateFoodStatusById = ({ id, status }) => {
  return request({
    method: 'patch',
    url: '/manage/updateFoodStatusById',
    data: {
      id,
      status,
    },
  })
}

// 批量删除food
export const manageBatchDeleteFoods = (arrayIds) => {
  return request({
    method: 'delete',
    url: '/manage/BatchDeleteFoodsByIds',
    params: {
      ids: [...arrayIds],
    },
  })
}

// 添加food及口味做法
export const manageAddFood = (fd) => {
  return request({
    method: 'post',
    url: '/manage/addFood',
    data: fd,
    headers: {
      'Content-Type': 'multipart/form-data', // 显式指定内容类型
    },
  })
}

// 根据id查找food
export const manageGetFoodById = ({ id }) => {
  return request({
    url: '/manage/getFoodById',
    params: {
      id,
    },
  })
}

// 提交更新food
export const manageUpdateFoodById = (fd) => {
  return request({
    method: 'patch',
    url: '/manage/updateFoodById',
    data: fd,
    headers: {
      'Content-Type': 'multipart/form-data', // 显式指定内容类型
    },
  })
}

// 模糊查询套餐w
export const manageQuerySetmealLikeByNameOrCategoryIdOrStatus = ({
  name,
  categoryName: categoryId,
  status,
}) => {
  return request({
    url: '/manage/querySetMealLikeByNameOrCategoryIdOrStatus',
    params: {
      name,
      categoryId,
      status,
    },
  })
}

// 批量删除套餐
export const manageBatchDeleteSetMealsByIds = (ids) => {
  return request({
    method: 'delete',
    url: '/manage/BatchDeleteSetMealsByIds',
    params: {
      ids: ids,
    },
  })
}
// 根据id删除套餐
export const manageDeleteSetMealById = ({ id }) => {
  return request({
    method: 'delete',
    url: '/manage/deleteSetMealById',
    params: {
      id,
    },
  })
}
// 根据id修改套餐的status
export const manageUpdateSetMealStatusById = ({ id, status }) => {
  return request({
    method: 'patch',
    url: '/manage/updateSetMealStatusById',
    data: {
      id,
      status,
    },
  })
}

// 添加套餐
export const manageAddSetMeal = (fd) => {
  return request({
    method: 'post',
    url: '/manage/addSetMeal',
    data: fd,
    headers: {
      'Content-Type': 'multipart/form-data', // 显式指定内容类型
    },
  })
}
// 根据id查询套餐
export const manageGetSetMealById = ({ id }) => {
  return request({
    url: '/manage/getSetMealById',
    params: {
      id,
    },
  })
}

// 提交更新套餐
export const manageUpdateSetMealById = (fd) => {
  return request({
    method: 'patch',
    url: '/manage/updateSetMealById',
    data: fd,
  })
}

// 添加套餐菜品
export const manageAddSetmealDish = (addSetmealDishList) => {
  return request({
    method: 'post',
    url: '/manage/addSetmealDish',
    data: addSetmealDishList,
  })
}
